import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import "../src/plugins/elements"

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

//全局变量
import Golbe from './Globe'
Vue.use(Golbe)

//全局组件
import MyList from './components/MyList.vue'
Vue.component(MyList.name,MyList)
//登陆全局组件
import Login from './views/login.vue'
Vue.component('LoginName',Login)
//注册全局组件
import register from './views/register.vue'
Vue.component(register.name,register)
router.beforeEach((to,from,next)=>{
  if(to.path == '/order'||to.path=='shoppingcart'||to.path=='collect'){
     if(store.state.token){
        next();
     }
  }else{
    next(from.path+"?dialogVisibles=true");
  }
  next()
})
Vue.use(ElementUI);
Vue.config.productionTip = false
Vue.prototype.$axios = axios
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
